<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>Document</title>
		<link rel="stylesheet" type="text/css" href="../css/footer.css">
		<link rel="stylesheet" type="text/css" href="../css/dynamic.css">
	</head>
	<style type="text/css">
		.dynamic_info{
			position: relative;
		}
		.back{
			position: absolute;
		    top: 0;
		    left: 10px;
		    font-size: 20px;
		}
	</style>
	<body>
		<div class="dynamic_info">
			<!-- <img src="../img/logo.png" width="100%">
			<a href="javascript:history.back(-1)" class="back underlining"><</a>
			<div class="infor">
				<p>Lucy</p>
				<p>陪你度过漫长岁月</p>
				<p class="girl flex">
					<img src="../img/female-s.png" height="7px"> 23
				</p>
			</div> -->
		</div>
		<div class="content-wrap">
			<p class="dynamic">动态</p>
			<!-- <div class="content">
				<a href="#" class="underlining">
					<div class="flex">
						<div><img src="../img/logo.png" width="50px"></div>
						<div>
							<p class="username">小静静</p>
							<p class="girl flex">
								<img src="../img/female-s.png" height="7px"> 23
							</p>
						</div>
					</div>
					<p class="wz">有在南山的朋友吗？</p>
					<div class="flex pic">
						<img src="../img/logo.png">
					</div>
					<div class="flex xs-r">
						<p>0.1km</p>
						<img src="../img/break.png" height="5px" class="break">
						<p>5分钟前</p>
						<img src="../img/break.png" height="5px" class="break">
						<p>1080阅读</p>
					</div>
				</a>
				<div class="flex xs-r">
					<div class="addlike">
						<img src="../img/like-n.png" height="15px">
						<span>15</span>
					</div>
					<div>
						<img src="../img/comment.png" height="15px">
						<span>6</span>
					</div>
					<div class="chat">
						<img src="../img/chat.png" height="15px">
					</div>
				</div>
			</div> -->
			<!-- <div class="content">
				<a href="#" class="underlining">
					<div class="flex">
						<div><img src="../img/logo.png" width="50px"></div>
						<div>
							<p class="username">小静静</p>
							<p class="girl flex">
								<img src="../img/female-s.png" height="7px"> 23
							</p>
						</div>
					</div>
					<p class="wz">有在南山的朋友吗？</p>
					<div class="flex pic">
						<img src="../img/logo.png">
						<img src="../img/logo.png">
						<img src="../img/logo.png">
						<img src="../img/logo.png">
					</div>
					<div class="flex xs-r">
						<p>0.1km</p>
						<img src="../img/break.png" height="5px" class="break">
						<p>5分钟前</p>
						<img src="../img/break.png" height="5px" class="break">
						<p>1080阅读</p>
					</div>
				</a>
				<div class="flex xs-r">
					<div class="addlike">
						<img src="../img/like-n.png" height="15px">
						<span>15</span>
					</div>
					<div>
						<img src="../img/comment.png" height="15px">
						<span>6</span>
					</div>
					<div class="chat">
						<img src="../img/chat.png" height="15px">
					</div>
				</div>
			</div> -->
		</div>
	</body>
</html>
<script src="../js/jquery-3.3.1.js"></script>
<script type="text/javascript">
	// get_user_info();
	//获取url传来的参数
	 function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        //接收URL中的参数phone
        var uccount = getUrlParam('ucount');
        console.log(uccount);
       
	 		                                
        /*查询用户动态*/
     /*   $.ajax({
        	url:"/meiyou/dongtai/selectAllDongtaiByAccount",
        	type:'post',
        	data:"uccount="+uccount,
        	success:function(data){
        		console.log(data);
        		var datas=data.extend.list;
        		if(datas.length==0){
        			$('.content-wrap').append('暂时没有动态');
        		}
        	}
        });*/



        /*查询用户信息*/
        $.ajax({
        	url:"/meiyou/dongtai/selectUserById",
        	type:'post',
        	data:"uccount="+uccount,
        	success:function(data){
        		console.log(data);
        		var datas=data.extend.user;
        		if(datas.uSex=='女'){
        			$('.dynamic_info').append("<img src='"+datas.uImg+"' width=\"100%\">" +
					"<a href=\"javascript:history.back(-1)\" class=\"back underlining\"><</a>" +
					"<div class=\"infor\">" +
					"<p>"+datas.uCount+"</p>" +
					"<p>"+datas.uName+"</p>" +
					"<p class=\"girl flex\">" +
					"<img src=\"../img/female-s.png\" height=\"7px\">"+datas.uOld +
					"</p>" +
					"</div>");
        		}else{
        			$('.dynamic_info').append("<img src='"+datas.uImg+"' width=\"100%\">" +
					"<a href=\"javascript:history.back(-1)\" class=\"back underlining\"><</a>" +
					"<div class=\"infor\">" +
					"<p>"+datas.uCount+"</p>" +
					"<p>"+datas.uName+"</p>" +
					"<p class=\"boy flex\">" +
					"<img src=\"../img/male-s.png\" height=\"7px\">"+datas.uOld +
					"</p>" +
					"</div>");
        		}
        		
        	}
        })



	$.post('/meiyou/dongtai/selectAllDongtaiByAccount',{account:uccount},function(data){
		var datas=data.extend.list;
		$.each(datas,function(i,value){
			showuser(value);
		});	
	});


	function showuser(data){
		$.post('/meiyou/dongtai/selectUserById',{uccount:uccount},function(res) {
			var user=res.extend.user;
			sekdynamic(data,user);

		})
	}

	//查询动态
	function sekdynamic(dynamic,user){
		if(user.uSex=="男"){
			$('.content-wrap').append("<div class=\"content\">" +
				"<a href='details-infor.html?id="+dynamic.tId+"' class=\"underlining\">" +
				"<div class=\"flex\">" +
				"<div><img src='"+user.uImg+"' width=\"50px\" style='border-radius: 100%'></div>" +
				"<div>" +
				"<p class=\"username\">"+user.uName+"</p>" +
				"<p class=\"boy flex\">" +
				"<img src=\"../img/male-s.png\" height=\"7px\">"+user.uOld +
				"</p>" +
				"</div>" +
				"</div>" +
				"<p class=\"wz\">"+dynamic.tContext+"</p>" +
				"<div class=\"flex pic\" id='"+dynamic.tId+"'>" +
				
				"</div>" +
				"<div class=\"flex xs-r\">" +
				
				"<img src=\"../img/break.png\" height=\"5px\" class=\"break\">" +
				"<p>"+dynamic.tTime+"</p>" +
				"<img src=\"../img/break.png\" height=\"5px\" class=\"break\">" +
				"</div>" +
				"</a>" +
				"<div class=\"flex xs-r\">" +
				"<div class=\"chat\ id='"+user.uCount+"'>" +
				"<img src=\"../img/chat.png\" height=\"15px\">" +
				"</div>" +
				"</div>" +
				"</div>");
		}else{
			$('.content-wrap').append("<div class=\"content\">" +
				"<a href='details-infor.html?id="+dynamic.tId+"' class=\"underlining\">" +
				"<div class=\"flex\">" +
				"<div><img src='"+user.uImg+"' width=\"50px\" style='border-radius: 100%'></div>" +
				"<div>" +
				"<p class=\"username\">"+user.uName+"</p>" +
				"<p class=\"girl flex\">" +
				"<img src=\"../img/female-s.png\" height=\"7px\">"+user.uOld +
				"</p>" +
				"</div>" +
				"</div>" +
				"<p class=\"wz\">"+dynamic.tContext+"</p>" +
				"<div class=\"flex pic\" id='"+dynamic.tId+"'>" +
				
				"</div>" +
				"<div class=\"flex xs-r\">" +
				
				"<img src=\"../img/break.png\" height=\"5px\" class=\"break\">" +
				"<p>"+dynamic.tTime+"</p>" +
				"<img src=\"../img/break.png\" height=\"5px\" class=\"break\">" +
				"</div>" +
				"</a>" +
				"<div class=\"flex xs-r\">" +
				"<div class=\"chat\" id='"+user.uCount+"'>" +
				"<img src=\"../img/chat.png\" height=\"15px\">" +
				"</div>" +
				"</div>" +
				"</div>");
			
		}
		var id=dynamic.tId;
		var img=dynamic.tImg;
		var imgs=JSON.parse(img);
		console.log(imgs);
		$.each(imgs,function(i,val){
			$('#'+id).append("<img src='"+val+"' height='100px' width='100px'>")
		});	



		}
		
$(document).on('click','.chat',function(){

	var toUser=$(this).attr('id');
	 $.post('/meiyou/addFriend',{toUser:toUser},function(data){
        layer.msg(data.msg,{icon:6,time:1000},function(){
			window.location.href='friendsss.html';
		})
      })

});

</script>